﻿using Permission.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace Permission.Controllers.Filter
{
    public class OperateAttribute : ActionFilterAttribute
    {
        public IUserService UserService { get; set; }

        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            //Do Something...
            var user = UserService.LoadUser(null);
            if (user == null)
            {
                filterContext.Result = new JsonResult
                {
                    Data = new { message = "不合法操作,未能进入" },
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                };
            }
        }
    }
}
